<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>

<style>
  .mainArea>.mainBody .selectorDiv{
        margin-top: 0;
    }
    .mainArea>.mainBody .selectorDiv>.selectorName{
        line-height: 28px;
        float: left;
        padding-right: 6px;
        vertical-align: middle;
        font-size: 12px;
        color: #2e2e2e;
    }
    .mainArea>.mainBody .selectorDiv>.selectorName>span{
        color: red;
    }
    .mainArea>.mainBody .selectorDiv>.listGroup{
        float: left;
        width: 164px;
        height: 28px;
    }
    .mainArea>.mainBody .selectorDiv>.listGroup>.btnLeft{
        width: 110px;
        font-size: 12px;
        color: #ffffff;
        text-align: left;
        padding-left: 20px;
        padding-right: 0px;
        margin-left: 0;
        border-right: 0;
        padding: 4px 5px 4px 15px;
    }
    .mainArea>.mainBody .selectorDiv>.listGroup>.dropDownList{
        width: 163px;
    }
</style>

<div class="mainBody" style="overflow: auto;width:680px">

       <?php echo form_open_multipart('sign/do_sign'); ?>
	<div class="btnArea floatFix">
	<input type="hidden" name='os' value=<?php echo $cur_os;?> />
		<div class="search noMarginTop fontDinpro">
                <label for="start">OS：</label>
            <div class="selectorDiv">
            <div class="locationGroup listGroupDown listGroup">
                <a class="btnLeft btnPrimary fontDinpro" data-toggle="dropdown" href="javascript:void(0)" link="">
                    <?php
                            echo $os[$cur_os];
                    ?>
                </a>
                <a class="btnRight btnPrimary" data-toggle="dropdown" href="javascript:void(0)"><span class="caretBottom"></span></a>
                <ul class="dropDownList fontDinpro">
                    <?php foreach($os as $k=>$r): ?>
                        <li>
                            <a href="javascript:void(0)" class="fontDinpro" link="<?php echo backend_url($language.'/sign/view/os'); ?>/<?php echo $k; ?>">
                                <?php echo $r; ?>
                            </a>
                        </li>
                    <?php endforeach; ?>
                </ul>
            </div>
        </div>
        </div>
            <div class="search noMarginTop fontDinpro">
                <label for="start">标识：</label>
                <input type="text" class='text-input' name='tag' value="" />
            </div>
            <div class="search noMarginTop fontDinpro">
                <label for="start">游戏包：</label>
                <input type="file" id="apk_file" name="apk_file"/>
                <button class="btn searchBtn searchFileBtn" type="button" onclick="apk_file.click();">选择文件</button>
                <label id="u_file_p" class="fileName"></label>
        		<button class="btn searchBtn" href="javascript:void(0)" style='left: 330px; top: 0px; position: absolute;' type='submit'>SUMBIT</button>
            </div>
            
	</div>
       <?php echo form_close(); ?>
    <div class="tableContent">
        <table class="fontDinpro">
            <thead>
            <tr>
                <th style="width: 80px;">任务ID</th>
                <th>上传文件</th>
                <th style="width: 100px;">操作系统</th>
                <th style="width: 100px;">签名状态</th>
                <th style="width: 120px;">提交时间</th>
                <td style="width: 120px;">删除</td>
            </tr>
            </thead>
            <tbody>
             <tr>
                <th style="width: 80px;">任务ID</th>
                <th>上传文件</th>
                <th style="width: 100px;">操作系统</th>
                <th style="width: 100px;">签名状态</th>
                <th style="width: 120px;">提交时间</th>
                <th style="width: 120px;">删除</th>
            </tr>
            <?php foreach($list as $v) : ?>
                <tr class="lowTr">
                	<td><?php echo $v['id'];?></td>
                    <td>
                    	<a href='<?php echo $this->config->item('res_domain').$v['uri']; ?>'>
                    		<?php echo $v['tag']; ?>
                    	</a>
                    </td>
                   	<td>
                        <?php
                        $className;
                        switch($os[$v['os']]){
                            case "ios":
                                $className = "";
                                break;
                            case "android":
                                $className = "bgAndroidGreen";
                                break;
                            case "wp":
                                $className = "bgBlue";
                                break;
                        }
                        ?>
                        <span class="colorLabel <?php echo $className; ?>"><?php echo $os[$v['os']]; ?></span>
                   	</td>
                    <td>
                    <?php switch($v['status']){
                    	case 0:
                    		echo '<span class="colorLabel bgBlue" style="display: inline-flex;">等待开始</span>';
                    		break;
                    	case 1:
                    		echo '<span class="colorLabel bgOrange" style="display: inline-flex;">进行中</span>';
                    		break;
                    	case 2:
                    		echo "<span class='colorLabel bgGreen bgBtn' onclick='location.href=\"".$this->config->item('res_domain').$v['outfile']."\"'>点击下载</span>";
                    		break;
                    	case 3:
                    		echo '<span class="colorLabel bgBlack" style="display: inline-flex;">暂停</span>';
                    		break;
                    	default:
                    		echo '<span class="colorLabel bgRed" style="display: inline-flex;">出错了</span>';
                    		break;
                    } ?></td>
                   <td><?php echo date('y-m-d H:i:s',$v['date']); ?></td>
                   <td>
                   		<button class="tableBtn" onclick="beSureDelete('','<?php echo backend_url($this->language."/sign/del/$cur_os/".$v['id']); ?>')">
                            <div class="delIcon"></div>Delete
                        </button>
                   </td>
                </tr>
            <?php endforeach; ?>
            <tr style="height: 33px;"></tr>
            </tbody>
        </table>
    </div>


</div>

    <script language="JavaScript">
    function changeversion(event){
		$("#ver").val($(event.currentTarget).val());
    }

    function handleFileSelect(evt) {
        var files = evt.target.files; // FileList object
        // Loop through the FileList and render image files as thumbnails.
        for (var i = 0, f; f = files[i]; i++) {
            var reader = new FileReader();

            // Closure to capture the file information.
            reader.onload = (function(theFile) {
                return function(e) {
                    // Render thumbnail.
                    u_file_p.innerHTML = decodeURIComponent(theFile.name);
                    $(u_file_p).attr("title",decodeURIComponent(theFile.name));
                };
            })(f);

            // Read in the image file as a data URL.
            reader.readAsDataURL(f);
        }
    }
    document.getElementById('apk_file').addEventListener('change', handleFileSelect, false);

</script>